﻿<%@ Page Title="" Language="C#" MasterPageFile="~/MainSite.Master" AutoEventWireup="true" CodeBehind="BusinessTargetManagement.aspx.cs" Inherits="BSCMFF.Web.Pages.BSC_Setup.BusinessTargetManagement" %>
<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Default">
    </telerik:RadAjaxLoadingPanel>
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1">
        
    <telerik:RadGrid ID="RadGridStrategicTargets" runat="server" AutoGenerateHierarchy="True"
         DataSourceID="EntityDataSourceStrategicTargets" CellSpacing="0" 
        GridLines="None" AutoGenerateColumns="False" 
        onupdatecommand="RadGridStrategicTargets_UpdateCommand" 
        ondeletecommand="RadGridStrategicTargets_DeleteCommand" 
        oninsertcommand="RadGridStrategicTargets_InsertCommand">
            
            <ClientSettings AllowExpandCollapse="true"></ClientSettings>
         <MasterTableView DataSourceID="EntityDataSourceStrategicTargets" CommandItemDisplay="Top" EditMode="PopUp"
             DataKeyNames="Strategic_Target_ID" HierarchyLoadMode="Client">
            <DetailTables>
                <%--Business Solution table--%>
                <telerik:GridTableView DataKeyNames="ID" DataSourceID="EntityDataSourceBusinessSolutions" 
                    runat="server" EditMode="PopUp" CommandItemDisplay="Top" HierarchyLoadMode="Client" > 
                    <ParentTableRelation>
                        <telerik:GridRelationFields DetailKeyField="Strategic_Target_FK" MasterKeyField="Strategic_Target_ID" />
                    </ParentTableRelation>
                    <DetailTables>
                    <%--KPIs table--%>
                        <telerik:GridTableView DataKeyNames="KPI_ID" DataSourceID="EntityDataSourceKPIs" runat="server"
                            CommandItemDisplay="Top" EditMode="PopUp" HierarchyLoadMode="Client">
                            <ParentTableRelation>
                                <telerik:GridRelationFields DetailKeyField="Solution_FK" MasterKeyField="ID" />
                            </ParentTableRelation>
                            <Columns>
                                <telerik:GridBoundColumn DataField="KPI_ID" Visible="false"
                                     DataType="System.Int32" 
                                     FilterControlAltText="Filter KPI_ID column" 
                                     HeaderText="KPI_ID" ReadOnly="True" 
                                     SortExpression="KPI_ID" UniqueName="KPI_ID">
                                 </telerik:GridBoundColumn>
                                 <telerik:GridBoundColumn DataField="Name" 
                                     FilterControlAltText="Filter Name column" HeaderText="KPI" 
                                     SortExpression="Name" UniqueName="Name">
                                 </telerik:GridBoundColumn>
                                 <telerik:GridBoundColumn DataField="Description" 
                                     FilterControlAltText="Filter Description column" HeaderText="Description" 
                                     SortExpression="Description" UniqueName="Description">
                                 </telerik:GridBoundColumn>
                                 <telerik:GridBoundColumn DataField="Perspective.Name" DataType="System.String" 
                                     FilterControlAltText="Filter Perspective column" HeaderText="Perspective" 
                                     SortExpression="Perspective" UniqueName="Perspective">
                                 </telerik:GridBoundColumn>
                                 <telerik:GridButtonColumn CommandName="Edit" Text="Edit">
                                 </telerik:GridButtonColumn>
                                 <telerik:GridButtonColumn CommandName="Delete" Text="Delete">
                                 </telerik:GridButtonColumn>
                            </Columns>
                            
                            <CommandItemSettings ExportToPdfText="Export to PDF" AddNewRecordText="Add new KPI"
                            ShowRefreshButton="false"></CommandItemSettings>

                            <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column"></RowIndicatorColumn>

                            <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column"></ExpandCollapseColumn>
                            <EditFormSettings EditFormType="WebUserControl" UserControlName="~/UserControls/Details/KPIDetails_new.ascx"
                            PopUpSettings-Modal="true" InsertCaption="Add new KPI" CaptionFormatString="Edit KPI: {0}"
                            CaptionDataField="Name">
                                <PopUpSettings Width="600" />
                                <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
                            </EditFormSettings>
                               
                        </telerik:GridTableView>
                        
                    </DetailTables> <%--end of KPIs table--%>
                    <Columns>
                        <telerik:GridBoundColumn DataField="ID" Visible="false"
                            DataType="System.Int32" 
                            FilterControlAltText="Filter Solution ID column" 
                            HeaderText="Solution_ID" ReadOnly="True" 
                            SortExpression="ID" UniqueName="SolutionID">
                        </telerik:GridBoundColumn>
                        <telerik:GridBoundColumn DataField="Solution" 
                            FilterControlAltText="Filter Solution column" HeaderText="Solution" 
                            SortExpression="Solution" UniqueName="Solution">
                        </telerik:GridBoundColumn>
                        <telerik:GridButtonColumn CommandName="Edit" Text="Edit">
                         </telerik:GridButtonColumn>
                         <telerik:GridButtonColumn CommandName="Delete" Text="Delete">
                         </telerik:GridButtonColumn>
                    </Columns>
                    
                    <EditFormSettings EditFormType="WebUserControl" UserControlName="~/UserControls/Details/BusinessSolutionDetails.ascx"
                    PopUpSettings-Modal="true" InsertCaption="Add new Business Solution" CaptionFormatString="Edit Business Solution: {0}"
                CaptionDataField="Solution">
                        <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
                        <PopUpSettings Width="600" />
                    </EditFormSettings>
                <CommandItemSettings ExportToPdfText="Export to PDF" AddNewRecordText="Add new Business Solution"
                            ShowRefreshButton="false"></CommandItemSettings>

                <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column"></RowIndicatorColumn>

                <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column"></ExpandCollapseColumn>

               
                </telerik:GridTableView>
            </DetailTables> <%--end of Business Solution table--%>
            
            
            <%--<CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>--%>

            <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column"></RowIndicatorColumn>

            <ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column"></ExpandCollapseColumn>

             <Columns>
                 <telerik:GridBoundColumn DataField="Strategic_Target_ID" Visible="false"
                     DataType="System.Int32" 
                     FilterControlAltText="Filter Strategic_Target_ID column" 
                     HeaderText="Strategic_Target_ID" ReadOnly="True" 
                     SortExpression="Strategic_Target_ID" UniqueName="Strategic_Target_ID">
                 </telerik:GridBoundColumn>
                 <telerik:GridBoundColumn DataField="Name" 
                     FilterControlAltText="Filter Name column" HeaderText="Target" 
                     SortExpression="Name" UniqueName="Name">
                 </telerik:GridBoundColumn>
                 <telerik:GridBoundColumn DataField="Description" 
                     FilterControlAltText="Filter Description column" HeaderText="Description" 
                     SortExpression="Description" UniqueName="Description">
                 </telerik:GridBoundColumn>
                 <telerik:GridBoundColumn DataField="Perspective.Name" DataType="System.String" 
                     FilterControlAltText="Filter Perspective column" HeaderText="Perspective" 
                     SortExpression="Perspective" UniqueName="Perspective">
                 </telerik:GridBoundColumn>
                 <telerik:GridBoundColumn DataField="ExpectedDate" DataType="System.DateTime" DataFormatString="{0:d}"
                     FilterControlAltText="Filter ExpectedDate column" HeaderText="ExpectedDate" 
                     SortExpression="ExpectedDate" UniqueName="ExpectedDate">
                 </telerik:GridBoundColumn>
                 <telerik:GridButtonColumn CommandName="Edit" Text="Edit">
                 </telerik:GridButtonColumn>
                 <telerik:GridButtonColumn CommandName="Delete" Text="Delete">
                 </telerik:GridButtonColumn>
             </Columns>
             <%--<CommandItemTemplate> 
                <asp:Button ID="Button1" Text="Add new Strategic Target" 
                 Runat="server" CommandName="InitInsert"></asp:Button> 
            </CommandItemTemplate> --%>

            <CommandItemSettings AddNewRecordText="Add New Strategic Target" ShowRefreshButton="false" ShowExportToCsvButton="true"
                ShowExportToExcelButton="true" ShowExportToPdfButton="true" ShowExportToWordButton="true" />
            <EditFormSettings EditFormType="WebUserControl" UserControlName="~/UserControls/Details/StrategicTargetDetails.ascx"
            PopUpSettings-Modal="true" InsertCaption="Add new Strategic Target" CaptionFormatString="Edit Strategic Target: {0}"
                CaptionDataField="Name" >
                <PopUpSettings Width="600" />
                <EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
            </EditFormSettings>
            
         </MasterTableView>
         <ExportSettings IgnorePaging="true" ExportOnlyData="true" FileName="Strategic Targets" ></ExportSettings>
        <FilterMenu EnableImageSprites="False"></FilterMenu>

        <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Default"></HeaderContextMenu>
    </telerik:RadGrid>
</telerik:RadAjaxPanel>
    <asp:EntityDataSource ID="EntityDataSourceStrategicTargets" runat="server" 
        ConnectionString="name=BSCEntities" DefaultContainerName="BSCEntities" 
        EnableFlattening="False" EntitySetName="Strategic_Target" 
         Include="Perspective">
    </asp:EntityDataSource>
    <asp:EntityDataSource ID="EntityDataSourceBusinessSolutions" runat="server" 
        ConnectionString="name=BSCEntities" DefaultContainerName="BSCEntities" 
        EnableFlattening="False" EntitySetName="Business_Solution" 
        Where="@Strategic_Target_FK == it.Strategic_Target_FK" EnableDelete="True" 
        EnableInsert="True" EnableUpdate="True">
        <WhereParameters>
            <asp:SessionParameter Type="Int32"  
                Name="Strategic_Target_FK" SessionField="Strategic_Target_FK" />
        </WhereParameters>
    </asp:EntityDataSource>
    <asp:EntityDataSource ID="EntityDataSourceKPIs" runat="server" 
        ConnectionString="name=BSCEntities" DefaultContainerName="BSCEntities" 
        EnableDelete="True" EnableFlattening="False" EnableInsert="True" 
        EnableUpdate="True" EntitySetName="KPIs" Include="Perspective"
        Where="@Solution_FK == it.Solution_FK" >
        <WhereParameters>
            <asp:SessionParameter Type="Int32"  
                Name="Solution_FK" SessionField="Solution_FK" />
        </WhereParameters>
    </asp:EntityDataSource>
</asp:Content>
